package com.woniuxy.businessassembly.controller;

import com.woniuxy.businessassembly.dao.HotelFacilitiesFunctionsMapper;
import com.woniuxy.businessassembly.model.HotelSettle;
import com.woniuxy.businessassembly.service.IHotelSettleService;
import com.woniuxy.common.Result;
import com.woniuxy.hotel.api.BusinessSettled;
import com.woniuxy.hotel.form.SettledForm;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author kevin kwok
 * @create 2021-05-25 9:52
 */
@Slf4j
@RestController
public class BusinessSettledController implements BusinessSettled {

    @Resource
    private IHotelSettleService settleService;


    @Override
    public Result newBusiness(SettledForm settledForm) {
        log.info("新入驻申请列表{}",settledForm);
        HotelSettle settle = new HotelSettle();
        BeanUtils.copyProperties(settledForm,settle);
        int i = settleService.newBusiness(settle);
        return new Result(true,"成功",i);
    }

    @Override
    public Result checkBusiness(String hotelName) {
        log.info("审核入驻申请{}",hotelName);
        int i = settleService.checkBusiness(hotelName);
        if(i==0){
            return new Result(false,"修改失败，已经审核过了",i);
        }
        return new Result(true,"审核通过",i);
    }
}
